package com.bwie.redkids.widgt;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.sax.StartElementListener;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.bwie.redkids.AboutUsActivity;
import com.bwie.redkids.MapActivity;
import com.bwie.redkids.R;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;

public class SlidingMenuWidget {

	private static final String TAG = "SlidingMenuWidght";
	private static SlidingMenu menu;
	private static TextView tvAboutUs;
	private static Context mContext;
	private static TextView tv_call_paone;
	private static TextView tv_sliding_map;

	public static SlidingMenu getSlidingMenu(Context context) {
		menu = new SlidingMenu(context);
		mContext = context;
		// 设置模式
		menu.setMode(SlidingMenu.RIGHT);
		// 设置触摸屏幕的模式
		menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
		menu.setShadowWidth(80);

		// 设置滑动菜单视图的宽度
		menu.setBehindOffset(50);
		// 设置渐入渐出效果的值
		menu.setFadeDegree(0.35f);

		menu.attachToActivity((Activity) context, SlidingMenu.SLIDING_CONTENT);
		// 为侧滑菜单设置布局
		menu.setMenu(R.layout.slind);
		// 找寻视图中的控件
		initView();
		// 定义监听
		onClick();
		return menu;

	}

	private static void onClick() {
		tvAboutUs.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// 跳转
				Intent intent = new Intent(mContext, AboutUsActivity.class);
				mContext.startActivity(intent);
			}
		});

		tv_call_paone.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// 用intent启动拨打电话
				Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
						+ "13870896967"));

			}
		});
		tv_sliding_map.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(mContext, MapActivity.class);
				mContext.startActivity(intent);
			}
		});
	}

	private static void initView() {
		if (menu != null) {
			tvAboutUs = (TextView) menu.findViewById(R.id.tv_about_us);
			tv_call_paone = (TextView) menu.findViewById(R.id.tv_call_paone);
			tv_sliding_map = (TextView) menu.findViewById(R.id.tv_sliding_map);
			Log.i(TAG, ",AD,FFFFKFKFFK");
		}
	}
}
